from flask import Flask,Blueprint
from flask_restful import Resource, Api,fields,reqparse,marshal
from flask_script import Manager
from app import simple_page
app = Flask("huzheng")
#print app.name
app.register_blueprint(simple_page)
manager = Manager(app)
api = Api(app)

parser = reqparse.RequestParser()
parser.add_argument('name',type=str)
parser.add_argument('age',type=int)
@manager.command
def hello():
    print "hello"


@manager.command
def startserver():
    app.run(host="0.0.0.0", port=8765,debug=True)


class HelloWorld(Resource):
    resource_fields = {
    "name":fields.String,
    "age":fields.Integer
}
    def get(self):
        self.hello()
        args = parser.parse_args()
        return marshal(args,self.resource_fields)

    def put(self):
        return "goodbye"

    def post(self):
        return "thankyou"

    def delete(self):
        return "and you"
    def hello(self):
        print "helloworld"

api.add_resource(HelloWorld, '/')
if __name__ == '__main__':
    manager.run()
